<template>
  <div>
    <!--搜索表单-->
    <div style="margin-bottom: 10px"></div>
    <div>
      <el-input style="width: 150px;" placeholder="请输入图书名称" v-model="params.bookName"></el-input>
      <el-input style="width: 150px;margin-left: 5px" placeholder="请输入标准码" v-model="params.bookNo"></el-input>
      <el-input style="width: 150px;margin-left: 5px" placeholder="请输入用户名称" v-model="params.userName"></el-input>
      <el-button style="margin-left: 5px" type="primary" @click="load"><i class="el-icon-search">搜索</i></el-button>
      <el-button style="margin-left: 5px" type="warning" @click="reset"><i class="el-icon-refresh-right">重置</i></el-button>
    </div>
    <div style="margin-bottom: 10px"></div>
    <el-table :data="tableData" border stripe row-key="id" default-expand-all>
      <el-table-column prop="id" label="编号" width="40px"></el-table-column>
      <el-table-column prop="bookName" label="图书名称"></el-table-column>
      <el-table-column prop="bookNo" label="图书标准码"></el-table-column>
      <el-table-column prop="userId" width="150px" label="用户ID"></el-table-column>
      <el-table-column prop="userName" label="用户名称"></el-table-column>
      <el-table-column prop="userPhone" label="用户电话"></el-table-column>
      <el-table-column prop="score" label="积分"></el-table-column>
      <el-table-column prop="createtime" label="借书时间"></el-table-column>
      <el-table-column prop="days" label="借书天数"></el-table-column>
      <el-table-column prop="status" label="状态"></el-table-column>
      <el-table-column prop="returnDate" label="归还日期"></el-table-column>
      <el-table-column prop="realDate" label="实际归还日期"></el-table-column>

      <el-table-column label="操作" width="150px">
        <template v-slot="scope">
          <el-popconfirm
              title="确认删除这行数据吗？"
              @confirm="del(scope.row.id)">
            <el-button type="danger" slot="reference">删除</el-button>
          </el-popconfirm>
        </template>
      </el-table-column>

    </el-table>
    <div style="margin-top: 20px"></div>
    <!--  分页  -->
    <div>
      <el-pagination
          background
          :current-page="params.pageNum"
          :page-size="params.pageSize"
          layout="prev, pager, next"
          @current-change="handleCurrentChange"
          :total="total">
      </el-pagination>
    </div>

  </div>
</template>

<script>
import request from "@/utils/request";
import Cookies from "js-cookie";
export default {
  name: 'RevertList',
  data(){
    return {
      admin: Cookies.get('admin') ? JSON.parse(Cookies.get('admin')) : {},
      tableData: [],
      total: 0,
      pid:null,
      dialogFormVisible:false,
      form:{},
      formLabelWidth: '100px',
      params: {
        pageNum: 1,
        pageSize: 10,
        bookName: '',
        bookNo:'',
        userName:''
      }
    }
  },
      created() {
        console.log("==================")
        this.load()
      },
      methods: {
        load() {
          request.get('/borrow/pageRevert', {params: this.params}).then(res => {
            if (res.code === '200') {
              this.tableData = res.data.list
              this.total = res.data.total
            }
          })
        },
        reset() {
          this.params = {
            pageNum: 1,
            pageSize: 10,
            name: '',
            phone: '',
            email: ''
          }
          this.load()
        },
        handleCurrentChange(pageNum) {
          //点击分页按钮出发分页
          this.params.pageNum = pageNum
          this.load()
        },
        del(id) {
          request.delete("/borrow/deleteRevert/" + id).then(res => {
            if (res.code === '200') {
              this.$message.success("删除OK!")
              this.load()
            } else {
              this.$notify.error(res.code)
            }
          })
        },
        returnBook(row){

        }
      }}


</script>

<style scoped>

</style>
